home *** CD-ROM | disk | FTP | other *** search
- Path: news.ucdavis.edu!quad!knight
- From: knight@quad.cs.ucdavis.edu (James Knight)
- Newsgroups: comp.lang.c,comp.unix.programmer
- Subject: Re: Q: '\n' character - Making a better fgets?
- Followup-To: comp.lang.c,comp.unix.programmer
- Date: 19 Apr 1996 22:07:13 GMT
- Organization: University of California, Davis
- Message-ID: <4l92qh$ft7@mark.ucdavis.edu>
- References: <31616F63.481D@lava.weeg.uiowa.edu> <DpBuF6.83C@ukpsshp1.serigate.philips.nl> <3169994D.665ACF69@cs.ucl.ac.uk> <4l6flq$rck@mark.ucdavis.edu> <4l8dmuINN6lf@keats.ugrad.cs.ubc.ca>
- NNTP-Posting-Host: quad.cs.ucdavis.edu
- X-Newsreader: TIN [version 1.2 PL2]
-
- Kazimir Kylheku (c2a192@ugrad.cs.ubc.ca) wrote:
- : In article <4l6flq$rck@mark.ucdavis.edu>,
- : James Knight <knight@quad.cs.ucdavis.edu> wrote:
- : > 4.5MB, 1MB,
- : > short lines one line
- : > ----------- --------
- : >1) fgetc/fputc 23.00 5.32
- : >2) getc/putc 17.56 4.09
- : >3) fgets/fputs 17.80 N/A
- : >4) my_getline 17.52 3.96
- : >5) freadln 19.70 4.20
- : >6) reimplement 19.82 4.44
- : >7) optimize 18.22 4.22
- : >8) read/write 9.65 1.46
-
- : >Now, this actually suprised the heck out of me, so I reran the test
- : >for 2, 3, 4 and 5 a number of times. Even though I wrote my_getline,
- : >I never expected it to be as fast as the getc/putc version. Could
-
- : Told you so. :) I'm not a _total_ idiot, you know...
-
- You were right about the getc/putc version versus the fgetc/fgetc
- version, but that isn't what suprised me. What suprised me was that
- the my_getline version, with it's use of fgets and strlen, was
- faster than the getc/putc version. I wrote my_getline for simplicity,
- to make an easier to use fgets, not for speed (since I still don't
- have the same intuitive understanding for optimization that I do for
- programming). So, the question I have is why did version 4 run
- faster than version 2? From looking at the respective codes and with
- my understanding of getc/putc versus fgets/strlen, it shouldn't have.
-
- Jim
-
-